<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .father {
            width: 300px;
            border: 1px solid red;
            /* 创建了BFC， 盒子会检测浮动的子元素的高度 */
            overflow: hidden;
        }

        .son1,
        .son2 {
            width: 100px;
            height: 100px;
            background-color: pink;
            float: left;
        }

        .son2 {
            background-color: purple;
        }
    </style>
</head>

<body>
    <div class="father">
        <div class="son1"></div>
        <div class="son2"></div>
    </div>
</body>

</html>